package org.dtrd.config.pay;

import org.dtrd.config.wechat.config.WechatUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 支付配置
 *
 * @author xiao
 * @date 2022/6/6 11:14 AM
 */
@Configuration
public class PayConfiguration {

    @Value("${dtrd.pay.valid_time}")
    private Integer validTime;

    @Value("${dtrd.pay.wechat.app_id}")
    private String wechatPayMchId;
    @Value("${dtrd.pay.wechat.notify_url}")
    private String wechatPayNotifyUrl;
    @Value("${dtrd.pay.wechat.serial_no}")
    private String serialNo;
    @Value("${dtrd.pay.wechat.private_key_v3}")
    private String privateKeyV3;
    @Value("${dtrd.pay.wechat.private_key_v2}")
    private String privateKeyV2;

    @Value("${dtrd.domain.api}")
    private String apiRootUrl;

    @Bean
    public void initPayConfiguration() {
        PayConfig.setValidTime(validTime);
        PayConfig.setWechatPay(wechatPayMchId, apiRootUrl + wechatPayNotifyUrl, serialNo, privateKeyV2, privateKeyV3);
    }
}
